package com.raymond.controller;

import com.raymond.entity.employee.EmployeeEntity;
import com.raymond.entity.commons.DtoResult;
import com.raymond.entity.commons.PageResponse;
import com.raymond.service.EmployeeService;
import com.raymond.entity.employee.EmployeePageQueryReqVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * desc-
 *
 * @author houmenghe
 * @date 2025/04/16 19:17
 **/
@RestController
@RequestMapping("/employee")
public class EmployeeController {

    @Autowired
    private EmployeeService employeeService;

    @PostMapping("/searchList")
    public DtoResult<PageResponse<EmployeeEntity>> searchList(@RequestBody EmployeePageQueryReqVo query) {
        return DtoResult.ok(employeeService.searchList(query));
    }

    @PostMapping("/save")
    public DtoResult<Void> save(@RequestBody EmployeeEntity entity) {
        employeeService.save(entity);
        return DtoResult.ok(null);
    }

    @PostMapping("/update")
    public DtoResult<Void> update(@RequestBody EmployeeEntity entity) {
        employeeService.update(entity);
        return DtoResult.ok(null);
    }

    @PostMapping("/delete/{id}")
    public DtoResult<Void> delete(@PathVariable("id") Long id) {
        employeeService.delete(id);
        return DtoResult.ok(null);
    }

}
